package com.dingreading.cloud.ssxcx.controller;

import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.common.util.aliyun.MstCdnUtil;
import com.dingreading.cloud.ssxcx.service.XcxStudentCenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/xcx/center")
@Api(tags = "小程序-学生个人中心")
public class XcxStudentCenterController {
    @Resource
    private XcxStudentCenterService xcxStudentCenterService;

    @ApiOperation(value = "错题本(课中)分页列表")
    @PostMapping(value = "/pageListMistake", produces = "application/json; charset=UTF-8")
    public R<Object> pageListMistake(
            HttpServletRequest request,
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "伙伴uid") @RequestParam(value = "agencyUid") String agencyUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "学生studentUid") @RequestParam(value = "studentUid") String studentUid,
            @ApiParam(value = "科目Uid") @RequestParam(value = "projectUid", required = false) String projectUid
    ) {
        R<Object> r = MstCdnUtil.getIp(request);
        if (R.isError(r))
            return r;
        String ip = (String) r.getData();

        return xcxStudentCenterService.pageListMistake(pageUtil, agencyUid, storeUid, studentUid, projectUid, ip);
    }

    @ApiOperation(value = "作业点评(课后)分页列表")
    @PostMapping(value = "/pageListHomework", produces = "application/json; charset=UTF-8")
    public R<Object> pageListHomework(
            HttpServletRequest request,
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "伙伴uid") @RequestParam(value = "agencyUid") String agencyUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "学生studentUid") @RequestParam(value = "studentUid") String studentUid,
            @ApiParam(value = "科目Uid") @RequestParam(value = "projectUid", required = false) String projectUid
    ) {
        R<Object> r = MstCdnUtil.getIp(request);
        if (R.isError(r))
            return r;
        String ip = (String) r.getData();

        return xcxStudentCenterService.pageListHomework(pageUtil, agencyUid, storeUid, studentUid, projectUid, ip);
    }

    @ApiOperation(value = "学习轨迹分页列表")
    @PostMapping(value = "/pageListLearning", produces = "application/json; charset=UTF-8")
    public R<Object> pageListLearning(
            HttpServletRequest request,
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "伙伴uid") @RequestParam(value = "agencyUid") String agencyUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "学生studentUid") @RequestParam(value = "studentUid") String studentUid,
            @ApiParam(value = "科目Uid") @RequestParam(value = "projectUid", required = false) String projectUid
    ) {
        R<Object> r = MstCdnUtil.getIp(request);
        if (R.isError(r))
            return r;
        String ip = (String) r.getData();

        return xcxStudentCenterService.pageListLearning(pageUtil, agencyUid, storeUid, studentUid, projectUid, ip);
    }

    @ApiOperation(value = "活动记录分页列表")
    @PostMapping(value = "/pageListSchedule", produces = "application/json; charset=UTF-8")
    public R<Object> pageListSchedule(
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "伙伴uid") @RequestParam(value = "agencyUid") String agencyUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "学生studentUid") @RequestParam(value = "studentUid") String studentUid,
            @ApiParam(value = "科目Uid") @RequestParam(value = "projectUid", required = false) String projectUid
    ) {
        return xcxStudentCenterService.pageListSchedule(pageUtil, agencyUid, storeUid, studentUid, projectUid);
    }

}
